From 40828c657dd0c9e654d143393b4ca81b6d23ed76 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Wed, 7 Jul 2004 17:49:47 +0000 Subject: [PATCH] bitkeeper revision 1.1041.18.1 (40ec37bbEfVooGtkbbrgCf3ZWEhJEg) More x86_64 stuff. Now links, but a bunch of stuff is stubbed out. Will it run? :-) --- xen/arch/x86/Makefile | 12 +- xen/arch/x86/Rules.mk | 13 +- xen/arch/x86/boot/x86_64.S | 229 ++++++++++++++++++++++------------- xen/arch/x86/trampoline.S | 6 +- xen/arch/x86/x86_64/xen.lds | 2 +- xen/common/Makefile | 2 +- xen/drivers/acpi/Makefile | 2 +- xen/drivers/char/Makefile | 2 +- xen/drivers/pci/Makefile | 2 +- xen/include/asm-x86/system.h | 4 + 10 files changed, 173 insertions(+), 101 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 039df504ef..1290f0420f 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -9,8 +9,15 @@ endif OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S)) OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c)) +ifeq ($(TARGET_SUBARCH),x86_32) LINK_BASE := 0xFC500000 # Xen is linked here LOAD_BASE := 0x00100000 # Xen is loaded here +endif + +ifeq ($(TARGET_SUBARCH),x86_64) +LINK_BASE := 0xFFFF830000100000 # Xen is linked here +LOAD_BASE := 0x0000000000100000 # Xen is loaded here +endif # What happens here? We link object files together, starting at LINK_BASE # (a very high address). But the bootloader cannot put things there, so we @@ -19,8 +26,9 @@ LOAD_BASE := 0x00100000 # Xen is loaded here # (NB. Linux gets round this by turning its image into raw binary, then # wrapping that with a low-memory bootstrapper.) default: boot/$(TARGET_SUBARCH).o $(OBJS) - $(LD) -r -o arch.o $(OBJS) - $(LD) $(LDFLAGS) boot/$(TARGET_SUBARCH).o $(ALL_OBJS) -o $(TARGET)-syms + $(LD) $(LDFLAGS) -r -o arch.o $(OBJS) + $(LD) $(LDFLAGS) -T $(TARGET_SUBARCH)/xen.lds -N \ + boot/$(TARGET_SUBARCH).o $(ALL_OBJS) -o $(TARGET)-syms objcopy -R .note -R .comment -S $(TARGET)-syms $(TARGET) $(BASEDIR)/tools/elf-reloc $(LINK_BASE) $(LOAD_BASE) $(TARGET) diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index 560b381845..2ecca1fffe 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -5,17 +5,16 @@ CC := gcc LD := ld CFLAGS := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing -O3 -CFLAGS += -iwithprefix include -Wall -Werror -fomit-frame-pointer +CFLAGS += -iwithprefix include -Wall -Werror -fomit-frame-pointer -pipe CFLAGS += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls -LDFLAGS := -T $(TARGET_SUBARCH)/xen.lds -N - ifeq ($(TARGET_SUBARCH),x86_32) -CFLAGS += -m32 -march=i686 -LDARCHFLAGS := --oformat elf32-i386 +CFLAGS += -m32 -march=i686 +LDFLAGS := --oformat elf32-i386 endif ifeq ($(TARGET_SUBARCH),x86_64) -CFLAGS += -m64 -LDARCHFLAGS := --oformat elf64-x86-64 +CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks +CFLAGS += -fno-asynchronous-unwind-tables +LDFLAGS := --oformat elf64-x86-64 endif diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 46af44607c..ab5219f64c 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -9,9 +9,8 @@ ENTRY(start) jmp __start - - .align 4 - + + .org 0x004 /*** MULTIBOOT HEADER ****/ /* Magic number indicating a Multiboot header. */ .long 0x1BADB002 @@ -19,11 +18,11 @@ ENTRY(start) .long 0x00000002 /* Checksum: must be the negated sum of the first two fields. */ .long -0x1BADB004 - -bad_cpu_msg: + + .org 0x010 .asciz "Bad CPU: does not support 64-bit (long) mode." bad_cpu: - mov $SYMBOL_NAME(bad_cpu_msg)-__PAGE_OFFSET,%esi + mov $0x100010,%esi # Error message mov $0xB8000,%edi # VGA framebuffer 1: mov (%esi),%bl test %bl,%bl # Terminate on '\0' sentinel @@ -41,19 +40,14 @@ bad_cpu: jmp 1b __start: + cld + cli + /* Set up a few descriptors: on entry only CS is guaranteed good. */ - lgdt %cs:nopaging_gdt_descr-__PAGE_OFFSET + lgdt %cs:0x1001f0 mov $(__HYPERVISOR_DS),%ecx mov %ecx,%ds mov %ecx,%es - mov %ecx,%fs - mov %ecx,%gs - ljmp $(__HYPERVISOR_CS32),$(1f)-__PAGE_OFFSET -1: lss stack_start-__PAGE_OFFSET,%esp - - /* Reset EFLAGS (subsumes CLI and CLD). */ - pushl $0 - popf /* We begin by interrogating the CPU for the presence of long mode. */ mov $0x80000000,%eax @@ -68,74 +62,93 @@ __start: /* Set up FPU. */ fninit - /* Set up CR4, except global flag which Intel requires should be */ - /* left until after paging is enabled (IA32 Manual Vol. 3, Sec. 2.5) */ - mov mmu_cr4_features-__PAGE_OFFSET,%ecx - and $0x7f,%cl # CR4.PGE (global enable) + /* Enable PAE in CR4. */ + mov $0x20,%ecx # X86_CR4_PAE mov %ecx,%cr4 - + cmp $(SECONDARY_CPU_FLAG),%ebx je start_paging - add $__PAGE_OFFSET,%ebx - push %ebx /* Multiboot info struct */ - push %eax /* Multiboot magic value */ - - /* Initialize BSS (no nasty surprises!) */ - mov $__bss_start-__PAGE_OFFSET,%edi - mov $_end-__PAGE_OFFSET,%ecx - sub %edi,%ecx - xor %eax,%eax - rep stosb - - /* Initialize low and high mappings of all memory with 4MB pages */ - mov $idle_pg_table-__PAGE_OFFSET,%edi - mov $0x1e3,%eax /* PRESENT+RW+A+D+4MB+GLOBAL */ -1: mov %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */ - stosl /* low mapping */ - add $(1<